unit EnumPrinter;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Printers, WinSpool, StdCtrls, FileCtrl;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure GetPapernames(sl: TStrings); 
type
  TPaperName      = array [0..63] of Char; 
  TPaperNameArray = array [1..High(Word) div SizeOf(TPaperName)] of TPaperName; 
  PPapernameArray = ^TPaperNameArray; 
var 
  Device, Driver, Port: array [0..255] of Char; 
  hDevMode: THandle; 
  i, numPaperformats: Integer;
  pPaperFormats: PPapernameArray;
begin
//  Printer.PrinterIndex := -1; // Standard printer
//  Printer.GetPrinter(Device, Driver, Port, hDevmode);
//    ShowMessage(  Printer.Printers.GetText );

//ShowMessage(Device);


  numPaperformats := WinSpool.DeviceCapabilities(Device, Port, DC_PAPERNAMES, nil, nil);
  if numPaperformats <> 0 then
  begin
    GetMem(pPaperformats, numPaperformats * SizeOf(TPapername));
    try
      WinSpool.DeviceCapabilities(Device, Port, DC_PAPERNAMES,
        PChar(pPaperFormats), nil);
      sl.Clear;
      for i := 1 to numPaperformats do sl.Add(pPaperformats^[i]);
    finally
      FreeMem(pPaperformats);
    end;
  end;

end;


procedure TForm1.Button1Click(Sender: TObject);
var
  Dir: string;
begin
  dir := 'asdfa';
  SelectDirectory('C:\winnt', 'c:\', Dir);
  showmessage(dir);
end;

end.
